﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LD.Common
{
    public static class MonitorEx
    {
        private static bool b_lock = false;
        private static readonly object lockObj = new object();
        public static bool Enter()
        {
            lock (lockObj)
            {
                if (b_lock)
                    return false;
                else
                {
                    b_lock = true;
                    return true;
                }
            }
        }
        public static void Exit()
        {
            lock (lockObj)
            {
                if (b_lock)
                    b_lock = false;
            }
        }
    }
}
